package io.renren.modules.labelhistory.service.impl;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.modules.user.entity.UserinfoEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.labelhistory.dao.LabelhistoryinfoDao;
import io.renren.modules.labelhistory.entity.LabelhistoryinfoEntity;
import io.renren.modules.labelhistory.service.LabelhistoryinfoService;


@Service("labelhistoryinfoService")
public class LabelhistoryinfoServiceImpl extends ServiceImpl<LabelhistoryinfoDao, LabelhistoryinfoEntity> implements LabelhistoryinfoService {

    @Autowired
    private LabelhistoryinfoDao labelhistoryinfoDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String labelid =(String) params.get("key");//模糊查询
        boolean blank = StringUtils.isBlank(labelid);
        QueryWrapper<LabelhistoryinfoEntity> queryWrapper;
        if(blank){
            queryWrapper = new QueryWrapper<LabelhistoryinfoEntity>();
        }else {
            queryWrapper = new QueryWrapper<LabelhistoryinfoEntity>().like("label_idCard",labelid);
        }
        IPage<LabelhistoryinfoEntity> page = this.page(
                new Query<LabelhistoryinfoEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

    @Override
    public void selectByLabelid(String labelid, Page<LabelhistoryinfoEntity> page) {
        labelhistoryinfoDao.selectByLabelid(labelid,page);
    }

    @Override
    public List<LabelhistoryinfoEntity> listByDate(String labelId, String startDate, String endDate) {
        return labelhistoryinfoDao.listByDate(labelId,startDate,endDate);
    }

}